<template>
    <div class="row">
        <el-checkbox v-model="comp.enabled">{{ comp.__classname__ }}</el-checkbox>
        <el-button round size="small" :icon="Document" @click="gm.toConsole(comp)"></el-button>
    </div>
    
    <div class="row-start">
        <el-text class="span-title" truncated>SpriteFrame</el-text>
        <el-input size="small" disabled :value="gm.targetName(comp.spriteFrame)" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>Direction</el-text>
        <el-select v-model="comp.direction" size="small">
            <el-option v-for="item in direction.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>CellSize</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="Model.cellSizeW">
            <template #suffix>
                <span>W</span>
            </template>
        </el-input-number>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="Model.cellSizeH">
            <template #suffix>
                <span>H</span>
            </template>
        </el-input-number>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>Spacing</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.spacing" />
    </div>
</template>

<script lang="ts" setup>
import { Document } from '@element-plus/icons-vue'
import gm from './gm';

const props = defineProps<{
    comp: CCComponent,
    update: Number,
}>()
const direction = cc.PageViewIndicator.Direction

class Model {
    static get comp() {
        return props.comp
    }

    static get cellSizeW() {
        return this.comp.cellSize.width
    }

    static set cellSizeW(value: number) {
        const ori = this.comp.cellSize
        ori.width = value
        this.comp.cellSize = ori
    }

    static get cellSizeH() {
        return this.comp.cellSize.height
    }

    static set cellSizeH(value: number) {
        const ori = this.comp.cellSize
        ori.height = value
        this.comp.cellSize = ori
    }
}
</script>